<template>
  <div class="box">
    <div class="nav">
      <span
        @click="qiehuan(index)"
        :class="{ navlist: true, static: index == statice }"
        v-for="(item, index) in nav"
        :key="index"
        >{{ item.name }}</span
      >
      <span class="reading">即将开始</span>
    </div>
    <div class="list">
      <div class="item" v-for="(item, index) in list" :key="index">
        <div class="left">
          <img :src="item.picture" alt="" />
        </div>
        <div class="right">
          <p>{{ item.name }}</p>
          <p>{{ item.unit }}</p>
          <p>爆爆团价</p>
          <p>
            <span class="jiage">{{ item.min_price }}</span>
            <span class="btn" @click="changestate(item)">{{
              item.status == 3 ? "已抢" : "马上抢"
            }}</span>
          </p>
          <p>
            <span class="yuanjia">50</span>
            <span class="xiaoliang">{{ item.month_saled_content }}份</span>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { tuan_list } from "../../../api/index.js";
export default {
  methods: {
    // 切换
    qiehuan(index) {
      this.statice = index;
      if (index == 0) {
        this.list = this.list1;
      } else {
        this.list = this.list2;
      }
    },
    // 按钮切换
    changestate(item) {
      console.log(item);
      item.status = 3;
      console.log(this.list);
    },
  },
  mounted() {
    tuan_list({ status: 0 }).then((res) => {
      console.log(res.data.list);
      this.list1 = res.data.list;
      this.list = this.list1;
    });
    tuan_list({ status: 1 }).then((res) => {
      console.log(res.data.list);
      this.list2 = res.data.list;
    });
  },
  data() {
    return {
      nav: [{ name: "正在抢购" }, { name: "上新预告" }],
      list: [],
      list1: [],
      list2: [],
      statice: 0,
      // state: false,
    };
  },
};
</script>

<style scoped>
.box {
  width: 100%;
}
.nav {
  width: 100%;
  font-size: 14px;
  padding-left: 10px;
  position: relative;
  padding-top: 10px;
  background-color: rgb(252, 82, 52);
  height: 40px;
  /* box-shadow:0 10px 10px 10px rgb(252, 82, 52); */
}
.nav .navlist {
  margin-right: 20px;
  color: rgb(240, 240, 240);
}
/* 点击后的颜色 */
.nav .static {
  color: rgb(201, 245, 91);
  font-weight: 800;
}
.nav .reading {
  position: absolute;
  top: -8px;
  left: 85px;
  font-size: 12px;
  padding: 0 5px;
  color: red;
  background-color: white;
  border-radius: 10px;
}
.list {
  width: 100%;
  padding: 0 10px;
  background-color: rgb(239, 241, 243);
  margin-bottom: 40px;
  height: 380px;
  overflow: auto;
}
.list .item {
  /* margin-bottom: 10px; */
  height: 120px;
  width: 100%;
  background-color: white;
  border-radius: 10px;
  display: flex;
  align-items: center;
  padding: 10px;
  margin: 10px 0;
}
.list .item .left img {
  width: 100px;
  height: 100px;
  background-color: rgb(64, 107, 215);
  /* margin-top: 100px; */
}
.list .item .right {
  width: 100%;
  margin-left: 10px;
}
.list .item .right p:nth-child(1) {
  font-size: 12px;
  color: gray;
}
.list .item .right p:nth-child(2) {
  font-size: 13px;
  font-weight: 800;
  margin: 5px 0;
}
.list .item .right p:nth-child(3) {
  font-size: 12px;
  color: red;
}
.list .item .right p:nth-child(4) {
  margin: 4px 0;
  width: 100%;
}
.list .item .right p:nth-child(5) {
  clear: both;
  width: 100%;
  font-size: 12px;
}
.list .item .right p:nth-child(4) .jiage {
  font-size: 18px;
  color: red;
  font-weight: 800;
  float: left;
}
.list .item .right p:nth-child(4) .btn {
  width: 60px;
  display: block;
  float: right;
  background-color: rgb(252, 82, 52);
  color: white;
  padding: 5px 0;
  font-size: 12px;
  border-radius: 15px;
  text-align: center;
  /* margin-left: 90px; */
}
.list .item .right p:nth-child(5) .yuanjia {
  color: gray;
}
.list .item .right p:nth-child(5) .xiaoliang {
  color: red;
  /* margin-left: 90px; */
  float: right;
}
</style>